import {formDownload} from 'nc-lightapp-front';
import {getQueryCondition} from "src/hrpub/common/utils/utils";

export default function exportRosterInfo(type) {
    const {
        searchModalValue,
        orgVal,
        queryOid,
        pageInfo,
        sort_field,
        rosterRefVal,
        isOrg
    } = this.props;
    let data = getQueryCondition(this.props, 'query');
    let postData = {
        ...data,
        pk_org: isOrg ? orgVal.refpk : '',//组织传值和pk_org_ref一样
        pk_org_ref: orgVal.refpk,
        oid: queryOid,
        pageInfo: {
            pageIndex: type === 'cur' ? pageInfo.pageIndex : "1",
            pageSize: type === 'cur' ? pageInfo.pageSize : pageInfo.total,
            total: pageInfo.total,
            totalPage: pageInfo.totalPage,
        },
        pk_rpt_def: rosterRefVal.refpk,
        sort_field: JSON.stringify(sort_field)
    };

    let paramData = {
        jsonStr: JSON.stringify(postData)
    };

    return formDownload({
        params: paramData,
        url: '/nccloud/hrhi/listrep/ListRptExportAction.do',
        enctype: 2
    });
}
